<template>
  <div>
    <input type="text" v-model="username">
    <button @click="sendUserName">点击将数据提交给父组件</button>
  </div>
</template>

<script>
export default {
  name: "Login",
  data(){
    return {
      username:''
    }
  },
  methods:{
    sendUserName(){
      // 触发自定义事件,$emit('事件名称',发送的事件参数)
      this.$emit('sendParentUserName',this.username);
    }
  }
}
</script>

<style scoped>

</style>